<%@ page pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ include file="/pages/common/taglib.jsp" %>
<html>
<head>
    <title>登录</title>
    <%@ include file="/pages/common/meta.jsp" %>
    <link rel="stylesheet" href="${ctx}/assets/css/style.css"/>
    <!-- basic styles -->

    <link href="${ctx}/assets-lib/ace/css/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="${ctx}/assets-lib/ace/css/font-awesome.min.css" />

    <!--[if IE 7]>
    <link rel="stylesheet" href="../../assets-lib/ace/css/font-awesome-ie7.min.css" />
    <![endif]-->

    <!-- page specific plugin styles -->

    <!-- fonts -->

    <link rel="stylesheet" href="${ctx}/assets-lib/ace/css/ace-fonts.css" />

    <!-- ace styles -->

    <link rel="stylesheet" href="${ctx}/assets-lib/ace/css/ace.min.css" />
    <link rel="stylesheet" href="${ctx}/assets-lib/ace/css/ace-rtl.min.css" />
    <link rel="stylesheet" href="${ctx}/assets-lib/ace/css/ace-skins.min.css" />

    <!--[if lte IE 8]>
    <link rel="stylesheet" href="../../assets-lib/ace/css/ace-ie.min.css" />
    <![endif]-->

    <!-- inline styles related to this page -->

    <!-- ace settings handler -->

    <script src="${ctx}/assets-lib/ace/js/ace-extra.min.js"></script>

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->

    <!--[if lt IE 9]>
    <script src="../../assets-lib/ace/js/html5shiv.js"></script>
    <script src="../../assets-lib/ace/js/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="warp">
    <div class="logo">
        <%--<img src="${ctx}/assets/images/logo.png" width="239" height="40" />--%>
        <%--<p class="logo_text">&copy; &nbsp;</p>--%>
    </div>
    <form name="loginform" id="loginform" method="post" action="${ctx}/j_spring_security_check">
        <div class="login_div">
            <div class="title">酒店管理平台—系统登录</div>
            <ul class="login_ul">
                <li>
                    <div class="">
                        <input type="text" placeholder="用户名" class="name_text" id="username" name="j_username"
                               onkeydown="valid_loginname(event);" value="hoteladmin"/>
                    </div>
                </li>
                <li>
                    <div class="">
                        <input type="password" placeholder="密码" class="name_pad" id="password" name="j_password"
                               onkeydown="if(event.keyCode == 13){login();return false;}" value="123456"/>
                    </div>
                </li>
                <c:if test="${param.error == true}">
                    <p class="red">
                        <c:choose>
                            <c:when test="${sessionScope['SPRING_SECURITY_LAST_EXCEPTION'].message=='Bad credentials'}">
                                用户名或密码错误
                            </c:when>
                            <c:when test="${sessionScope['SPRING_SECURITY_LAST_EXCEPTION'].message=='permission denied'}">
                                用户没有登陆权限，请联系平台管理员
                            </c:when>
                            <c:when test="${sessionScope['SPRING_SECURITY_LAST_EXCEPTION'].message=='user not found'}">
                                用户不存在
                            </c:when>
                            <c:when test="${sessionScope['SPRING_SECURITY_LAST_EXCEPTION'].message=='User is disabled'}">
                                账号不可用，请联系平台管理员
                            </c:when>
                            <c:when test="${sessionScope['SPRING_SECURITY_LAST_EXCEPTION'].message=='User account has expired'}">
                                账号已经过期，请联系平台管理员
                            </c:when>
                            <c:when test="${sessionScope['SPRING_SECURITY_LAST_EXCEPTION'].message=='User account is locked'}">
                                账号已经被锁定，请联系平台管理员
                            </c:when>
                            <c:when test="${sessionScope['SPRING_SECURITY_LAST_EXCEPTION'].message=='User credentials have expired'}">
                                用户权限已经过期，请联系平台管理员
                            </c:when>
                            <c:otherwise>
                                用户状态异常，请联系平台管理员
                            </c:otherwise>
                        </c:choose>
                    </p>
                </c:if>
            </ul>
            <div class="login_but"><input type="button" value="登录" onclick="login();" class="button"/> </div>
            <p style="text-align: center;margin-top: 20px;">还没有账号？赶紧开始<a href="${ctx}/hotel/register">申请入驻</a>吧！</p>
        </div>
    </form>
</div>
<!--[if !IE]> -->
<script src="${ctx}/assets-lib/ace/js/jquery-2.1.0.min.js"></script>
<!-- <![endif]-->

<!--[if IE]>
<script src="${ctx}/assets-lib/ace/js/jquery-1.11.0.min.js"></script>
<![endif]-->

<!--[if !IE]> -->
<script type="text/javascript">
    window.jQuery || document.write("<script src='${ctx}/asset-libs/ace/js/jquery-2.1.0.min.js'>" + "</" + "script>");
</script>
<!-- <![endif]-->

<!--[if IE]>
<script type="text/javascript">
    window.jQuery || document.write("<script src='${ctx}/asset-libs/ace/js/jquery-1.11.0.min.js'>"+"</"+"script>");
</script>
<![endif]-->

<%--<script type="text/javascript">
    if ("ontouchend" in document) document.write("<script src='${ctx}/asset-libs/ace/js/jquery.mobile.custom.min.js'>" + "</" + "script>");
</script>--%>

<script src="${ctx}/assets-lib/ace/js/bootstrap.min.js"></script>

<!--[if lte IE 8]>
<script src="${ctx}/assets-lib/ace/js/excanvas.min.js"></script>
<![endif]-->
<script type="text/javascript">
    $('#test').click(function () {
        $.ajax({
            url: app_path + '/portal/test',
            data: {'dt': '2016-08-01'},
            dataType: 'json',
            type: 'get',
            success: function (data) {
                console.log(data);
            }
        });
    });

    function login() {
        if ($("#username").val() == "") {
            alert("请输入用户名！");
            $("#username").focus();
        } else if ($("#j_password").val() == "") {
            alert("请输入口令！");
            $("#password").focus();
        } else {
            $("#loginform").submit();
        }
    }

    function valid_loginname(event) {
        if (event.keyCode == 13) {
            if ($("#username").val() == "") {
                alert("请输入用户名！");
                $("#username").focus();
            } else {
                $("#password").focus();
            }
        }
    }

    $(document).ready(function load() {
        $('#username').focus();
    });
</script>
</body>
</html>